package io.gitee.zhangbinhub.test.reactive.task

import io.gitee.zhangbinhub.acp.boot.base.BaseSpringBootScheduledAsyncTask
import io.gitee.zhangbinhub.acp.boot.log.LogAdapter
import io.gitee.zhangbinhub.acp.boot.websocket.reactive.AcpWebSocketServerReactive
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component

@Component("task2")
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
class Task2 @Autowired constructor(private val log: LogAdapter) : BaseSpringBootScheduledAsyncTask() {
    override fun beforeExecuteFun(): Boolean {
        return true
    }

    override fun executeFun(): Any? {
        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>我是定时任务2》》》》》》》》》》")
        val message = "这是websocket服务端消息"
        log.info("【websocket】广播 >>>>> $message")
        AcpWebSocketServerReactive.sendMessageToClient("$message----> 广播")
        log.info("【websocket】单播【1】 >>>>> $message")
        AcpWebSocketServerReactive.sendMessageToClient("$message----> 单播", "1")
        return true
    }

    override fun afterExecuteFun(result: Any) {}
}
